import Cookies from "js-cookie";

// chrome或者本地server获取token
export function getToken() {
    return Cookies.get("token");
}

/**
 * cookie保存token
 * @param {*} payload token
 * @param {*} time 有效时间(小时数)
 */
export function setToken(payload, time = 60 * 60 * 8) {
    const expire = new Date(new Date().getTime() + time * 60 * 60 * 1000);
    Cookies.set("token", payload, {
        expires: expire,
    });
}

// 移除token
export function removeToken() {
    Cookies.remove("token");
}
